3.192 \(\int \frac{(a+b \sec (e+f x))^2}{(c+d \sec (e+f x))^2} \, dx\)

Optimal. Leaf size=133 \[ \frac{a^2 x}{c^2}+\frac{(b c-a d)^2 \sin (e+f x)}{c f \left (c^2-d^2\right ) (c \cos (e+f x)+d)}+\frac{2 (b c-a d) \left (2 a c^2-a d^2-b c d\right ) \tanh ^{-1}\left (\frac{\sqrt{c-d} \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{c+d}}\right )}{c^2 f (c-d)^{3/2} (c+d)^{3/2}} \]

[Out]

(a^2*x)/c^2 + (2*(b*c - a*d)*(2*a*c^2 - b*c*d - a*d^2)*ArcTanh[(Sqrt[c - d]*Tan[(e + f*x)/2])/Sqrt[c + d]])/(c
^2*(c - d)^(3/2)*(c + d)^(3/2)*f) + ((b*c - a*d)^2*Sin[e + f*x])/(c*(c^2 - d^2)*f*(d + c*Cos[e + f*x]))

________________________________________________________________________________________

Rubi [A]  time = 0.284952, antiderivative size = 133, normalized size of antiderivative = 1., number of steps used = 5, number of rules used = 5, integrand size = 25, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.2, Rules used = {3941, 2790, 2735, 2659, 208} \[ \frac{a^2 x}{c^2}+\frac{(b c-a d)^2 \sin (e+f x)}{c f \left (c^2-d^2\right ) (c \cos (e+f x)+d)}+\frac{2 (b c-a d) \left (2 a c^2-a d^2-b c d\right ) \tanh ^{-1}\left (\frac{\sqrt{c-d} \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{c+d}}\right )}{c^2 f (c-d)^{3/2} (c+d)^{3/2}} \]

Antiderivative was successfully verified.

[In]

Int[(a + b*Sec[e + f*x])^2/(c + d*Sec[e + f*x])^2,x]

[Out]

(a^2*x)/c^2 + (2*(b*c - a*d)*(2*a*c^2 - b*c*d - a*d^2)*ArcTanh[(Sqrt[c - d]*Tan[(e + f*x)/2])/Sqrt[c + d]])/(c
^2*(c - d)^(3/2)*(c + d)^(3/2)*f) + ((b*c - a*d)^2*Sin[e + f*x])/(c*(c^2 - d^2)*f*(d + c*Cos[e + f*x]))

Rule 3941

Int[(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_))^(m_)*(csc[(e_.) + (f_.)*(x_)]*(d_.) + (c_))^(n_), x_Symbol] :> Int[
((b + a*Sin[e + f*x])^m*(d + c*Sin[e + f*x])^n)/Sin[e + f*x]^(m + n), x] /; FreeQ[{a, b, c, d, e, f, m, n}, x]
 && NeQ[b*c - a*d, 0] && IntegerQ[m] && IntegerQ[n] && LeQ[-2, m + n, 0]

Rule 2790

Int[((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)])^2, x_Symbol] :> -Simp[
((b^2*c^2 - 2*a*b*c*d + a^2*d^2)*Cos[e + f*x]*(a + b*Sin[e + f*x])^(m + 1))/(b*f*(m + 1)*(a^2 - b^2)), x] - Di
st[1/(b*(m + 1)*(a^2 - b^2)), Int[(a + b*Sin[e + f*x])^(m + 1)*Simp[b*(m + 1)*(2*b*c*d - a*(c^2 + d^2)) + (a^2
*d^2 - 2*a*b*c*d*(m + 2) + b^2*(d^2*(m + 1) + c^2*(m + 2)))*Sin[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e,
f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 - b^2, 0] && LtQ[m, -1]

Rule 2735

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b*x)/d
, x] - Dist[(b*c - a*d)/d, Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d
, 0]

Rule 2659

Int[((a_) + (b_.)*sin[Pi/2 + (c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x
]}, Dist[(2*e)/d, Subst[Int[1/(a + b + (a - b)*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}
, x] && NeQ[a^2 - b^2, 0]

Rule 208

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[-(a/b), 2]*ArcTanh[x/Rt[-(a/b), 2]])/a, x] /; FreeQ[{a,
b}, x] && NegQ[a/b]

Rubi steps

\begin{align*} \int \frac{(a+b \sec (e+f x))^2}{(c+d \sec (e+f x))^2} \, dx &=\int \frac{(b+a \cos (e+f x))^2}{(d+c \cos (e+f x))^2} \, dx\\ &=\frac{(b c-a d)^2 \sin (e+f x)}{c \left (c^2-d^2\right ) f (d+c \cos (e+f x))}-\frac{\int \frac{-c \left (2 a b c-\left (a^2+b^2\right ) d\right )-a^2 \left (c^2-d^2\right ) \cos (e+f x)}{d+c \cos (e+f x)} \, dx}{c \left (c^2-d^2\right )}\\ &=\frac{a^2 x}{c^2}+\frac{(b c-a d)^2 \sin (e+f x)}{c \left (c^2-d^2\right ) f (d+c \cos (e+f x))}+\frac{\left (c^2 \left (2 a b c-\left (a^2+b^2\right ) d\right )-a^2 d \left (c^2-d^2\right )\right ) \int \frac{1}{d+c \cos (e+f x)} \, dx}{c^2 \left (c^2-d^2\right )}\\ &=\frac{a^2 x}{c^2}+\frac{(b c-a d)^2 \sin (e+f x)}{c \left (c^2-d^2\right ) f (d+c \cos (e+f x))}+\frac{\left (2 \left (c^2 \left (2 a b c-\left (a^2+b^2\right ) d\right )-a^2 d \left (c^2-d^2\right )\right )\right ) \operatorname{Subst}\left (\int \frac{1}{c+d+(-c+d) x^2} \, dx,x,\tan \left (\frac{1}{2} (e+f x)\right )\right )}{c^2 \left (c^2-d^2\right ) f}\\ &=\frac{a^2 x}{c^2}+\frac{2 (b c-a d) \left (2 a c^2-b c d-a d^2\right ) \tanh ^{-1}\left (\frac{\sqrt{c-d} \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{c+d}}\right )}{c^2 (c-d)^{3/2} (c+d)^{3/2} f}+\frac{(b c-a d)^2 \sin (e+f x)}{c \left (c^2-d^2\right ) f (d+c \cos (e+f x))}\\ \end{align*}

Mathematica [A]  time = 0.642527, size = 136, normalized size = 1.02 \[ \frac{\frac{2 \left (a^2 \left (2 c^2 d-d^3\right )-2 a b c^3+b^2 c^2 d\right ) \tanh ^{-1}\left (\frac{(d-c) \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{c^2-d^2}}\right )}{\left (c^2-d^2\right )^{3/2}}+a^2 (e+f x)+\frac{c (b c-a d)^2 \sin (e+f x)}{(c-d) (c+d) (c \cos (e+f x)+d)}}{c^2 f} \]

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Sec[e + f*x])^2/(c + d*Sec[e + f*x])^2,x]

[Out]

(a^2*(e + f*x) + (2*(-2*a*b*c^3 + b^2*c^2*d + a^2*(2*c^2*d - d^3))*ArcTanh[((-c + d)*Tan[(e + f*x)/2])/Sqrt[c^
2 - d^2]])/(c^2 - d^2)^(3/2) + (c*(b*c - a*d)^2*Sin[e + f*x])/((c - d)*(c + d)*(d + c*Cos[e + f*x])))/(c^2*f)

________________________________________________________________________________________

Maple [B]  time = 0.085, size = 462, normalized size = 3.5 \begin{align*} 2\,{\frac{{a}^{2}\arctan \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) }{f{c}^{2}}}-2\,{\frac{\tan \left ( 1/2\,fx+e/2 \right ){a}^{2}{d}^{2}}{fc \left ({c}^{2}-{d}^{2} \right ) \left ( \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}c- \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}d-c-d \right ) }}+4\,{\frac{\tan \left ( 1/2\,fx+e/2 \right ) abd}{f \left ({c}^{2}-{d}^{2} \right ) \left ( \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}c- \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}d-c-d \right ) }}-2\,{\frac{c\tan \left ( 1/2\,fx+e/2 \right ){b}^{2}}{f \left ({c}^{2}-{d}^{2} \right ) \left ( \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}c- \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}d-c-d \right ) }}-4\,{\frac{{a}^{2}d}{f \left ( c+d \right ) \left ( c-d \right ) \sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}{\it Artanh} \left ({\frac{\tan \left ( 1/2\,fx+e/2 \right ) \left ( c-d \right ) }{\sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}} \right ) }+2\,{\frac{{a}^{2}{d}^{3}}{f{c}^{2} \left ( c+d \right ) \left ( c-d \right ) \sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}{\it Artanh} \left ({\frac{\tan \left ( 1/2\,fx+e/2 \right ) \left ( c-d \right ) }{\sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}} \right ) }+4\,{\frac{abc}{f \left ( c+d \right ) \left ( c-d \right ) \sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}{\it Artanh} \left ({\frac{\tan \left ( 1/2\,fx+e/2 \right ) \left ( c-d \right ) }{\sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}} \right ) }-2\,{\frac{{b}^{2}d}{f \left ( c+d \right ) \left ( c-d \right ) \sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}{\it Artanh} \left ({\frac{\tan \left ( 1/2\,fx+e/2 \right ) \left ( c-d \right ) }{\sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}} \right ) } \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+b*sec(f*x+e))^2/(c+d*sec(f*x+e))^2,x)

[Out]

2/f*a^2/c^2*arctan(tan(1/2*f*x+1/2*e))-2/f/c/(c^2-d^2)*tan(1/2*f*x+1/2*e)/(tan(1/2*f*x+1/2*e)^2*c-tan(1/2*f*x+
1/2*e)^2*d-c-d)*a^2*d^2+4/f/(c^2-d^2)*tan(1/2*f*x+1/2*e)/(tan(1/2*f*x+1/2*e)^2*c-tan(1/2*f*x+1/2*e)^2*d-c-d)*a
*b*d-2/f*c/(c^2-d^2)*tan(1/2*f*x+1/2*e)/(tan(1/2*f*x+1/2*e)^2*c-tan(1/2*f*x+1/2*e)^2*d-c-d)*b^2-4/f/(c+d)/(c-d
)/((c+d)*(c-d))^(1/2)*arctanh(tan(1/2*f*x+1/2*e)*(c-d)/((c+d)*(c-d))^(1/2))*a^2*d+2/f/c^2/(c+d)/(c-d)/((c+d)*(
c-d))^(1/2)*arctanh(tan(1/2*f*x+1/2*e)*(c-d)/((c+d)*(c-d))^(1/2))*a^2*d^3+4/f*c/(c+d)/(c-d)/((c+d)*(c-d))^(1/2
)*arctanh(tan(1/2*f*x+1/2*e)*(c-d)/((c+d)*(c-d))^(1/2))*a*b-2/f/(c+d)/(c-d)/((c+d)*(c-d))^(1/2)*arctanh(tan(1/
2*f*x+1/2*e)*(c-d)/((c+d)*(c-d))^(1/2))*b^2*d

________________________________________________________________________________________

Maxima [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sec(f*x+e))^2/(c+d*sec(f*x+e))^2,x, algorithm="maxima")

[Out]

Exception raised: ValueError

________________________________________________________________________________________

Fricas [B]  time = 0.621149, size = 1426, normalized size = 10.72 \begin{align*} \left [\frac{2 \,{\left (a^{2} c^{5} - 2 \, a^{2} c^{3} d^{2} + a^{2} c d^{4}\right )} f x \cos \left (f x + e\right ) + 2 \,{\left (a^{2} c^{4} d - 2 \, a^{2} c^{2} d^{3} + a^{2} d^{5}\right )} f x +{\left (2 \, a b c^{3} d + a^{2} d^{4} -{\left (2 \, a^{2} + b^{2}\right )} c^{2} d^{2} +{\left (2 \, a b c^{4} + a^{2} c d^{3} -{\left (2 \, a^{2} + b^{2}\right )} c^{3} d\right )} \cos \left (f x + e\right )\right )} \sqrt{c^{2} - d^{2}} \log \left (\frac{2 \, c d \cos \left (f x + e\right ) -{\left (c^{2} - 2 \, d^{2}\right )} \cos \left (f x + e\right )^{2} + 2 \, \sqrt{c^{2} - d^{2}}{\left (d \cos \left (f x + e\right ) + c\right )} \sin \left (f x + e\right ) + 2 \, c^{2} - d^{2}}{c^{2} \cos \left (f x + e\right )^{2} + 2 \, c d \cos \left (f x + e\right ) + d^{2}}\right ) + 2 \,{\left (b^{2} c^{5} - 2 \, a b c^{4} d + 2 \, a b c^{2} d^{3} - a^{2} c d^{4} +{\left (a^{2} - b^{2}\right )} c^{3} d^{2}\right )} \sin \left (f x + e\right )}{2 \,{\left ({\left (c^{7} - 2 \, c^{5} d^{2} + c^{3} d^{4}\right )} f \cos \left (f x + e\right ) +{\left (c^{6} d - 2 \, c^{4} d^{3} + c^{2} d^{5}\right )} f\right )}}, \frac{{\left (a^{2} c^{5} - 2 \, a^{2} c^{3} d^{2} + a^{2} c d^{4}\right )} f x \cos \left (f x + e\right ) +{\left (a^{2} c^{4} d - 2 \, a^{2} c^{2} d^{3} + a^{2} d^{5}\right )} f x +{\left (2 \, a b c^{3} d + a^{2} d^{4} -{\left (2 \, a^{2} + b^{2}\right )} c^{2} d^{2} +{\left (2 \, a b c^{4} + a^{2} c d^{3} -{\left (2 \, a^{2} + b^{2}\right )} c^{3} d\right )} \cos \left (f x + e\right )\right )} \sqrt{-c^{2} + d^{2}} \arctan \left (-\frac{\sqrt{-c^{2} + d^{2}}{\left (d \cos \left (f x + e\right ) + c\right )}}{{\left (c^{2} - d^{2}\right )} \sin \left (f x + e\right )}\right ) +{\left (b^{2} c^{5} - 2 \, a b c^{4} d + 2 \, a b c^{2} d^{3} - a^{2} c d^{4} +{\left (a^{2} - b^{2}\right )} c^{3} d^{2}\right )} \sin \left (f x + e\right )}{{\left (c^{7} - 2 \, c^{5} d^{2} + c^{3} d^{4}\right )} f \cos \left (f x + e\right ) +{\left (c^{6} d - 2 \, c^{4} d^{3} + c^{2} d^{5}\right )} f}\right ] \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sec(f*x+e))^2/(c+d*sec(f*x+e))^2,x, algorithm="fricas")

[Out]

[1/2*(2*(a^2*c^5 - 2*a^2*c^3*d^2 + a^2*c*d^4)*f*x*cos(f*x + e) + 2*(a^2*c^4*d - 2*a^2*c^2*d^3 + a^2*d^5)*f*x +
 (2*a*b*c^3*d + a^2*d^4 - (2*a^2 + b^2)*c^2*d^2 + (2*a*b*c^4 + a^2*c*d^3 - (2*a^2 + b^2)*c^3*d)*cos(f*x + e))*
sqrt(c^2 - d^2)*log((2*c*d*cos(f*x + e) - (c^2 - 2*d^2)*cos(f*x + e)^2 + 2*sqrt(c^2 - d^2)*(d*cos(f*x + e) + c
)*sin(f*x + e) + 2*c^2 - d^2)/(c^2*cos(f*x + e)^2 + 2*c*d*cos(f*x + e) + d^2)) + 2*(b^2*c^5 - 2*a*b*c^4*d + 2*
a*b*c^2*d^3 - a^2*c*d^4 + (a^2 - b^2)*c^3*d^2)*sin(f*x + e))/((c^7 - 2*c^5*d^2 + c^3*d^4)*f*cos(f*x + e) + (c^
6*d - 2*c^4*d^3 + c^2*d^5)*f), ((a^2*c^5 - 2*a^2*c^3*d^2 + a^2*c*d^4)*f*x*cos(f*x + e) + (a^2*c^4*d - 2*a^2*c^
2*d^3 + a^2*d^5)*f*x + (2*a*b*c^3*d + a^2*d^4 - (2*a^2 + b^2)*c^2*d^2 + (2*a*b*c^4 + a^2*c*d^3 - (2*a^2 + b^2)
*c^3*d)*cos(f*x + e))*sqrt(-c^2 + d^2)*arctan(-sqrt(-c^2 + d^2)*(d*cos(f*x + e) + c)/((c^2 - d^2)*sin(f*x + e)
)) + (b^2*c^5 - 2*a*b*c^4*d + 2*a*b*c^2*d^3 - a^2*c*d^4 + (a^2 - b^2)*c^3*d^2)*sin(f*x + e))/((c^7 - 2*c^5*d^2
 + c^3*d^4)*f*cos(f*x + e) + (c^6*d - 2*c^4*d^3 + c^2*d^5)*f)]

________________________________________________________________________________________

Sympy [F]  time = 0., size = 0, normalized size = 0. \begin{align*} \int \frac{\left (a + b \sec{\left (e + f x \right )}\right )^{2}}{\left (c + d \sec{\left (e + f x \right )}\right )^{2}}\, dx \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sec(f*x+e))**2/(c+d*sec(f*x+e))**2,x)

[Out]

Integral((a + b*sec(e + f*x))**2/(c + d*sec(e + f*x))**2, x)

________________________________________________________________________________________

Giac [A]  time = 1.45983, size = 332, normalized size = 2.5 \begin{align*} \frac{\frac{{\left (f x + e\right )} a^{2}}{c^{2}} + \frac{2 \,{\left (2 \, a b c^{3} - 2 \, a^{2} c^{2} d - b^{2} c^{2} d + a^{2} d^{3}\right )}{\left (\pi \left \lfloor \frac{f x + e}{2 \, \pi } + \frac{1}{2} \right \rfloor \mathrm{sgn}\left (-2 \, c + 2 \, d\right ) + \arctan \left (-\frac{c \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right ) - d \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right )}{\sqrt{-c^{2} + d^{2}}}\right )\right )}}{{\left (c^{4} - c^{2} d^{2}\right )} \sqrt{-c^{2} + d^{2}}} - \frac{2 \,{\left (b^{2} c^{2} \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right ) - 2 \, a b c d \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right ) + a^{2} d^{2} \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right )\right )}}{{\left (c^{3} - c d^{2}\right )}{\left (c \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right )^{2} - d \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right )^{2} - c - d\right )}}}{f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sec(f*x+e))^2/(c+d*sec(f*x+e))^2,x, algorithm="giac")

[Out]

((f*x + e)*a^2/c^2 + 2*(2*a*b*c^3 - 2*a^2*c^2*d - b^2*c^2*d + a^2*d^3)*(pi*floor(1/2*(f*x + e)/pi + 1/2)*sgn(-
2*c + 2*d) + arctan(-(c*tan(1/2*f*x + 1/2*e) - d*tan(1/2*f*x + 1/2*e))/sqrt(-c^2 + d^2)))/((c^4 - c^2*d^2)*sqr
t(-c^2 + d^2)) - 2*(b^2*c^2*tan(1/2*f*x + 1/2*e) - 2*a*b*c*d*tan(1/2*f*x + 1/2*e) + a^2*d^2*tan(1/2*f*x + 1/2*
e))/((c^3 - c*d^2)*(c*tan(1/2*f*x + 1/2*e)^2 - d*tan(1/2*f*x + 1/2*e)^2 - c - d)))/f